package com.gitee.ixtf.vertx.internal.converter

import com.gitee.ixtf.vertx.ParameterConverter
import graphql.schema.DataFetchingEnvironment
import io.vertx.ext.web.FileUpload
import io.vertx.ext.web.RoutingContext

object FileUploadParameterConverter : ParameterConverter<FileUpload?> {
  override suspend fun convert(env: DataFetchingEnvironment) =
      env.graphQlContext
          .get<RoutingContext>(RoutingContext::class.java)
          .fileUploads()
          ?.firstOrNull()

  override suspend fun convert(rc: RoutingContext) = rc.fileUploads()?.firstOrNull()
}
